package io.gitee.cloudladder.obsidian.swagger2.example.controller;

import io.gitee.cloudladder.obsidian.swagger2.annotation.ApiOperationSort;
import io.gitee.cloudladder.obsidian.swagger2.example.entity.BaseDataTypeParamObject;
import io.gitee.cloudladder.obsidian.swagger2.example.entity.ExtendDataTypeParamObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.time.LocalDate;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Slf4j
@Api(value = "Test Query Parameter Controller")
@RestController
public class TestQueryParameterController {

    @ApiOperationSort(0)
    @GetMapping("/test/query/boolean")
    public void testQueryBoolean(@RequestParam Boolean param) {
        log.info("testQueryBoolean: param = {}", param);
    }

    @ApiOperationSort(1)
    @GetMapping("/test/query/string")
    public void testQueryString(@RequestParam String param) {
        log.info("testQueryString: param = {}", param);
    }

    @ApiOperationSort(2)
    @GetMapping("/test/query/byte")
    public void testQueryByte(@RequestParam Byte param) {
        log.info("testQueryByte: param = {}", param);
    }

    @ApiOperationSort(3)
    @GetMapping("/test/query/short")
    public void testQueryShort(@RequestParam Short param) {
        log.info("testQueryShort: param = {}", param);
    }

    @ApiOperationSort(4)
    @GetMapping("/test/query/integer")
    public void testQueryInteger(@RequestParam Integer param) {
        log.info("testQueryInteger: param = {}", param);
    }

    @ApiOperationSort(5)
    @GetMapping("/test/query/long")
    public void testQueryLong(@RequestParam Long param) {
        log.info("testQueryLong: param = {}", param);
    }

    @ApiOperationSort(6)
    @GetMapping("/test/query/float")
    public void testQueryFloat(@RequestParam Float param) {
        log.info("testQueryFloat: param = {}", param);
    }

    @ApiOperationSort(7)
    @GetMapping("/test/query/double")
    public void testQueryDouble(@RequestParam Double param) {
        log.info("testQueryDouble: param = {}", param);
    }

    @ApiOperationSort(8)
    @GetMapping("/test/query/date")
    @ApiOperation(value = "testQueryDate", notes = "'yyyy-MM-dd hh:mm:ss' is supported")
    public void testQueryDate(@RequestParam Date param) {
        log.info("testQueryDate: param = {}", param);
    }

    @ApiOperationSort(9)
    @GetMapping("/test/query/localDate")
    @ApiOperation(value = "testQueryLocalDate", notes = "'yyyy-MM-dd' is supported")
    public void testQueryLocalDate(@RequestParam LocalDate param) {
        log.info("testQueryLocalDate: param = {}", param);
    }

    @ApiOperationSort(10)
    @GetMapping("/test/query/array/string")
    @ApiOperation(value = "testQueryArrayString", notes = "'a, b' is supported")
    public void testQueryArrayString(@RequestParam String[] param) {
        for(int i = 0; i < param.length; i ++) {
            log.info("testQueryArrayString: param[{}] = {}", i, param[i]);
        }
    }

    @ApiOperationSort(11)
    @GetMapping("/test/query/array/integer")
    @ApiOperation(value = "testQueryArrayInteger", notes = "'1, 2' is supported")
    public void testQueryArrayInteger(@RequestParam Integer[] param) {
        for(int i = 0; i < param.length; i ++) {
            log.info("testQueryArrayInteger: param[{}] = {}", i, param[i]);
        }
    }

    @ApiOperationSort(12)
    @GetMapping("/test/query/list/string")
    @ApiOperation(value = "testQueryListString", notes = "'a, b' is supported")
    public void testQueryListString(@RequestParam List<String> param) {
        for(int i = 0; i < param.size(); i ++) {
            log.info("testQueryListString: param[{}] = {}", i, param.get(i));
        }
    }

    @ApiOperationSort(13)
    @GetMapping("/test/query/list/integer")
    @ApiOperation(value = "testQueryListInteger", notes = "'1, 2' is supported")
    public void testQueryListInteger(@RequestParam List<Integer> param) {
        for(int i = 0; i < param.size(); i ++) {
            log.info("testQueryListInteger: param[{}] = {}", i, param.get(i));
        }
    }

    @ApiOperationSort(14)
    @GetMapping("/test/query/object/base")
    public void testQueryObjectBase(@ModelAttribute BaseDataTypeParamObject params) {
        log.info("testQueryObjectBase: param = {}", params);
    }

}

